import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 */
public class Test1 {
    /*public static int getData(){
        Scanner scanner = new Scanner(System.in);

        try {
            int a = scanner.nextInt();
            return a;
        }catch (InputMismatchException e){
            e.printStackTrace();
        }finally {
            System.out.println("执行finally的代码");
        }
        System.out.println("try-catch-finally执行完");
        if (scanner !=null){
            System.out.println("关闭Scanner");
            scanner.close();
        }
        return 0;
    }*/
    public static int getData(){
        Scanner scanner = new Scanner(System.in);
        try {
            int a = scanner.nextInt();
            return a;
        }catch (InputMismatchException e){
            e.printStackTrace();
        }finally {
            System.out.println("执行finally的代码");
            System.out.println("关闭Scanner");
            scanner.close();
        }
        System.out.println("try-catch-finally执行完");
       return 0;
    }
    public static void main(String[] args) {
        System.out.println(getData());
    }
}
